package ldh.im.util;

import io.netty.buffer.ByteBuf;
import ldh.im.dto.codec.BaseImCoder;
import ldh.im.TransferData;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;

public class TransferDataUtil {

//    private static final Logger LOGGER = LoggerFactory.getLogger(TransferDataUtil.class);

    public static int readHeader(ByteBuf in, TransferData transferData, int length) {
        int headLength = 0;
        for(int i=0; i<length; i++) {
            int lg = in.readInt();
            String key = ByteBufHelp.readString(in, lg, BaseImCoder.utf8);
            int vlg = in.readInt();
            String value = ByteBufHelp.readString(in, vlg, BaseImCoder.utf8);
//            transferData.addHeader(key, value);
            headLength += (lg + vlg + 8);
        }

        return headLength;
    }
}
